package com.zpark.controller;

import com.zpark.entity.patients.FirstAidGuides;
import com.zpark.service.FirstAidGuidesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/first-aid-guides")
public class FirstAidGuidesController {

    @Autowired
    private FirstAidGuidesService firstAidGuidesService;

    @GetMapping
    public List<FirstAidGuides> getAllGuides() {
        return firstAidGuidesService.list();
    }

    @GetMapping("/{id}")
    public FirstAidGuides getGuideById(@PathVariable Integer id) {
        return firstAidGuidesService.getById(id);
    }

    @PostMapping
    public boolean addGuide(@RequestBody FirstAidGuides guide) {
        return firstAidGuidesService.save(guide);
    }

    @PutMapping
    public boolean updateGuide(@RequestBody FirstAidGuides guide) {
        return firstAidGuidesService.updateById(guide);
    }

    @DeleteMapping("/{id}")
    public boolean deleteGuide(@PathVariable Integer id) {
        return firstAidGuidesService.removeById(id);
    }

    @GetMapping("/categories")
    public List<String> getAllCategories() {
        return firstAidGuidesService.getAllCategories();
    }
}